package it.asvp.asvp_portal.data.entity.domain;

import it.asvp.asvp_portal.asvp_util.enumerative.FileType;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@SuppressWarnings("serial")
@Entity
@Table(name = "file", catalog = "asvp_db", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class File extends BaseEntity {

  @Column(name = "name", unique = true, nullable = false)
  private String   name;

  @Column(name = "file_type", nullable = false, length = 50)
  @Enumerated(EnumType.STRING)
  private FileType type;

  @Column(name = "data", nullable = false)
  private byte[]   data;

  public File() {
  }

  public File(String name, FileType type, byte[] data, Date lastUpdate, Date createdOn) {
    this.name = name;
    this.type = type;
    this.data = data;
    this.lastUpdate = lastUpdate;
    this.createdOn = createdOn;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public FileType getType() {
    return this.type;
  }

  public void setType(FileType type) {
    this.type = type;
  }

  public byte[] getData() {
    return this.data;
  }

  public void setData(byte[] data) {
    this.data = data;
  }

}
